/**
 * Copyright (c) 2014 zhenrongbao.com, Inc. All Rights Reserved
 * @author: jiangshuguang
 * @Date  : 14-11-30
 * @Time  : 下午6:47
 * @brief :
 */
(function () {
   var $page = $('.page-wallet'),
       assets = P.data('assets');
    var data = {
        'wallet':parseFloat(assets.wallet.total),
        'demand':parseFloat(assets.demand.total),
        'term':parseFloat(assets.term1.amount)+parseFloat(assets.term3.amount)+parseFloat(assets.term6.amount),
        'iphone6':(assets.iphone6.credit?parseFloat(assets.iphone6.credit):0)
    };
    data['total'] =data['wallet']+data['demand']+data['term']+data['iphone6'];

    $page.find('.assets-cycle').highcharts({
        chart : {
            backgroundColor:'rgba(0,0,0,0)',
            borderColor:"#AAA"
        },

        credits : {
            enabled:false
        },

        title: {
            userHTML : true,
            text: '<div style="color:#4d5665;font-size:30px">'+'￥' + mathUtil.formatAmount(data.total,2)+ '</div>',
            color:'#FFF',
            align: 'center',
            verticalAlign: 'middle',
            y: -10
        },
        subtitle : {
            userHTML : true,
            text: '<div style="font-size:14px;padding-top:30px;color:#4d5665">资金总额</div>',
            verticalAlign:'middle',
            y:20
        },
        tooltip: {
            pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
        },
        legend: {
            borderColor: '#909090'
        },
        plotOptions: {
            pie: {
                borderWidth:"0px",
                size:"75%",
                dataLabels: {
                    enabled: true
                }
            }
        },

        series: [{
            type: 'pie',
            name: '占比',
            innerSize: '100%',
            data :[
                {
                    name:'钱包',
                    y:parseFloat(data.wallet),
                    dataLabels : {
                        enabled:false
                    },
                    color:'#f93'
                },
                {
                    name:'真融宝活期',
                    y:parseFloat(data.demand),
                    dataLabels : {
                        enabled:false
                    },
                    color:'#fec284'
                },
                {
                    name:'真融宝定期',
                    y:parseFloat(data.term),
                    dataLabels : {
                        enabled:false
                    },
                    color:'#ff6b36'
                },
                {
                    name:'我的果6宝',
                    y:parseFloat(data.iphone6),
                    dataLabels : {
                        enabled:false
                    },
                    color:'#ffac5c'
                }
            ]
        }]
    });
})();